package com.example.demo.repository;

import com.example.demo.model.Danmaku;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface DanmakuRepository extends JpaRepository<Danmaku, Long> {
    
    /**
     * 按创建时间降序查询所有弹幕
     */
    @Query(value = "SELECT d FROM Danmaku d ORDER BY d.createdTime DESC")
    List<Danmaku> findAllOrderByCreatedTimeDesc();
    
    /**
     * 按创建时间降序查询前N条弹幕
     */
    List<Danmaku> findByOrderByCreatedTimeDesc(Pageable pageable);
} 